﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using Dcms.Common;
using Dcms.BLL;
using Dcms.Model;

public partial class Admin_UserManage_AddNewUsers : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        CompetenceLib CL = new CompetenceLib();
        CL.IsLogin();
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        string strMsg = "";
        string strUserName = this.txt_AdminName.Text.Trim();
        if (strUserName == "")
        {
            RegisterStartupScript(this.ToString(), "<script>alert('请输入用户名！');</script>");
            return;
        }
        //string IsUCenter = ConfigurationManager.AppSettings["IsUCenter"].ToUpper();
        //if (IsUCenter == "TRUE")
        //{
        //    string strBackKey = ConfigurationManager.AppSettings["BackKey"];
        //    if (UCenterOperate.AddUser(strUserName, "123456", "", strBackKey, out strMsg) == true)
        //    {
        //        Dcms_AdminBLL aBll = new Dcms_AdminBLL();
        //        Dcms_AdminModel aModel = new Dcms_AdminModel();
        //        aModel.Admin_AddTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
        //        aModel.Admin_Email = "";
        //        aModel.Admin_LastIp = DcmsRequest.GetIP();
        //        aModel.Admin_LastTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
        //        aModel.Admin_LoginTimes = 0;
        //        aModel.Admin_Msn = "";
        //        aModel.Admin_Name = strUserName;
        //        aModel.Admin_Pwd = "e10adc3949ba59abbe56e057f20f883e";
        //        aModel.Admin_QQ = "";
        //        aModel.Admin_RoleId = 0;
        //        aBll.AddModel(aModel);

        //        Session.Add("Message", "新用户已添加，请通知其修改密码！");
        //        Session.Add("Url", "UserManage/UserList.aspx?id=" + strPermissionID);
        //        Response.Redirect("../Message.aspx");
        //    }
        //    else
        //    {
        //        RegisterStartupScript(this.ToString(), "<script>alert('" + strMsg + "');</script>");
        //    }
        //}
        //else
        //{
            Dcms_AdminBLL aBll = new Dcms_AdminBLL();
            Dcms_AdminModel aModel = new Dcms_AdminModel();
            aModel.Admin_AddTime = DateTime.Now;
            aModel.Admin_Email = "";
            aModel.Admin_LastIp = DcmsRequest.GetIP();
            aModel.Admin_LastTime = DateTime.Now;
            aModel.Admin_LoginTimes = 0;
            aModel.Admin_Msn = "";
            aModel.Admin_Name = strUserName;
            aModel.Admin_Pwd = "e10adc3949ba59abbe56e057f20f883e";
            aModel.Admin_QQ = "";
            aModel.Admin_RoleId = 0;
            aBll.AddModel(aModel);

            Session.Add("Message", "新用户已添加，请通知其修改密码！");
            Session.Add("Url", "UserManage/UserList.aspx?id=" + strPermissionID);
            Response.Redirect("../Message.aspx");
        //}
    }

    protected string strPermissionID
    {
        get
        {
            return Request.QueryString["PermissionID"] + "";
        }
    }
}